package com.fz.song.provider;

import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class MyWebAuthenticationDetails extends WebAuthenticationDetails {

    private boolean imageCodeIsRight;

    public boolean isImageCodeIsRight() {
        return this.imageCodeIsRight;
    }

    public MyWebAuthenticationDetails(HttpServletRequest request) {
        super(request);
        String captcha = request.getParameter("captcha");
        HttpSession session = request.getSession();
        String captcha1 = (String) session.getAttribute("captcha");
        if (!StringUtils.isEmpty(captcha1)) {
            session.removeAttribute("captcha");
            if (!StringUtils.isEmpty(captcha) && captcha.equals(captcha1)) {
                this.imageCodeIsRight = true;
            }
        }

    }
}
